﻿using Scap.Data;
using Scap.Info;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Scap.Core
{
    class CommandHandler
    {
        internal ScapCommandCollection GetUploadCommands()
        {
            ScapCommandCollection coll = new ScapCommandCollection();
        
            using (ScapData db = new ScapData())
            {
                var records = from d in db.Commands where d.Command == CommandType.PUT_EMPLOYEE_ON_DEVICES && d.Progress != ScapCommand.DONE select d;

                foreach (ScapCommand cmd in records)
                    coll.Add(cmd);
            }

            return coll;
      
        }

        internal void UpdateUploadCommand(ScapCommand cmd, int progress)
        {
            cmd.Progress = progress;
            ScapData db = new ScapData();
            db.Entry(cmd).State = System.Data.EntityState.Modified;
            db.SaveChanges();
        }
    }
}
